var app =new Vue({
	el:"#container",
	data:{
		user:{}
	},
	mounted(){
		this.userInfo();
	},
	methods:{
		userInfo(){
			axios({
				url:"yly-api/admin/queryEmpAccountByToken",
				method:"get",
				headers:{"token":localStorage.token,"url":window.location.pathname}
			}).then(function (res) {
				console.log(res);
				app.user=res.data;
			}).catch(function (error) {
				console.log(error.response.status);
				if (error.response.status==401){
					alert("权限不足，无法访问!");
					location.href="login.html";
				}else if (error.response.status==403){
					alert("用户已过期，请重新登录！");
					localStorage.token=null;
					location.href="login.html";
				}
			})
		},
		updateUser(){
			let data=new URLSearchParams();
			data.append("userName",app.user.userName);
			data.append("address",app.user.address);
			data.append("phone",app.user.phone);
			data.append("keyContactsphone",app.user.keyContactsphone);
			data.append("identityCode",app.user.identityCode);
			data.append("id",app.user.id);
			data.append("jobNumber",app.user.jobNumber);

			axios({
				url:"yly-api/admin/updateEmpAccount",
				method: "post",
				headers:{"token":localStorage.token,"url":window.location.pathname},
				data:data
			}).then(function (res) {
				console.log(res.data);
				if (res.data.code==200){
					if (res.data.data==true){
						alert("修改成功！");
					}else {
						alert("修改失败，请联系管理员！");
					}

				}else {
					location.href="500.html";
				}
			}).catch(function (error) {
				console.log(error.response.status);
				if (error.response.status==401){
					alert("权限不足，无法访问!");
					location.href="login.html";
				}else if (error.response.status==403){
					alert("用户已过期，请重新登录！");
					localStorage.token=null;
					location.href="login.html";
				}
			})
		}
	}
})